package validator

import (
	"github.com/wanchain/go-mpc/common/hexutil"
	"github.com/wanchain/go-mpc/log"
	mpcprotocol "github.com/wanchain/go-mpc/storeman/storemanmpc/protocol"
)

////////// xrp begin
func AddValidMpcXrpTx(args *mpcprotocol.SendEcData) error {
	log.SyslogInfo("AddValidMpcXrpTx", "data", args.String())
	hd, err := GetXrpHandler(args.TxHash, []byte(args.TxData))
	if err != nil {
		return mpcprotocol.ErrInvalidMpcTx
	}
	key := hd.GetKey()
	return addKeyValueToDB(key, []byte(args.TxData))
}

func GetHandlerByChain(chainType string, txHash hexutil.Bytes, TxData hexutil.Bytes) (TxHandler, error) {
	if chainType == "XRP" {
		return GetXrpHandler(txHash, TxData)
	}
	return XrpTxHandler{}, nil
}

////////////// xrp end
